import { d as defineEventHandler } from '../../../runtime.mjs';
import { URL, URLSearchParams } from 'url';
import 'node:http';
import 'node:https';
import 'node:zlib';
import 'node:stream';
import 'node:buffer';
import 'node:util';
import 'node:url';
import 'node:net';
import 'node:fs';
import 'node:path';
import 'fs';
import 'path';

const defineWrappedResponseHandler = (handler) => defineEventHandler(async (event) => {
  try {
    const data = await handler(event);
    return {
      data,
      code: 200,
      message: "\u8BF7\u6C42\u6210\u529F"
    };
  } catch (err) {
    return {
      error: err,
      message: "\u7CFB\u7EDF\u5F02\u5E38",
      code: 500
    };
  }
});

const listenRequest = (event, options) => {
  const params = getParams(event) || {};
  const callback = options[event.context.params._];
  return callback && callback({
    params,
    event
  });
};
function getParams(event) {
  const url = new URL("http://localhost:3000" + event.req.originalUrl);
  const searchParams = new URLSearchParams(url.search);
  return {
    ...event.context.params,
    ...Object.fromEntries(searchParams.entries())
  };
}

const navListLevel1 = [
  {
    name: "\u5173\u4E8E\u7533\u79D1",
    id: 1,
    path: "/about"
  },
  {
    name: "\u516C\u53F8\u52A8\u6001",
    id: 2,
    path: "/news"
  }
];
const navListLevel2 = [
  { pid: 1, name: "\u516C\u53F8\u6982\u51B5", id: 1 },
  { pid: 1, name: "\u548C\u8C10\u7406\u5FF5", id: 2 },
  { pid: 1, name: "\u5927\u4E8B\u8BB0", id: 3 },
  { pid: 1, name: "\u8463\u4E8B\u957F\u81F4\u8F9E", id: 4 },
  { pid: 1, name: "\u7BA1\u7406\u5C42", id: 5 },
  { pid: 2, name: "\u516C\u53F8\u65B0\u95FB", id: 6 },
  { pid: 2, name: "\u516C\u53F8\u8363\u8A89", id: 7 },
  { pid: 2, name: "\u5238\u5546\u8BC4\u7EA7", id: 8 },
  { pid: 2, name: "\u4F20\u5A92\u62A5\u5BFC", id: 9 },
  { pid: 2, name: "\u62DB\u6807\u516C\u544A", id: 10 },
  { pid: 2, name: "\u62DB\u8058\u4FE1\u606F", id: 11 }
];

const channelDetail = [
  {
    name: "\u516C\u53F8\u6982\u51B5",
    id: 1,
    info: {
      content: "\u7533\u79D1\u96C6\u56E2\u662F\u4E00\u5BB6\u4E13\u4E1A\u4ECE\u4E8B\u80A1\u4EFD\u5236\u8BC1\u5238\u6295\u8D44\u54A8\u8BE2\u3001\u8D44\u4EA7\u7BA1\u7406\u3001\u79C1\u52DF\u80A1\u6743\u6295\u8D44\u3001\u4FDD\u9669\u7406\u8D22\u3001\u57FA\u91D1\u7BA1\u7406\u3001\u8BC1\u5238\u7ECF\u7EAA\u3001\u8D44\u4EA7\u8BC4\u4F30\u3001\u8D44\u4EA7\u914D\u7F6E\u3001\u8D44\u4EA7\u8FD0\u8425\u3001\u8BC1\u5238\u671F\u8D27\u3001\u8BC1\u5238\u6295\u987E\u3001\u8BC1\u5238\u6295\u8D44\u987E\u95EE\u3001\u8BC1\u5238"
    }
  },
  {
    name: "\u548C\u8C10\u7406\u5FF5",
    id: 2,
    info: {
      content: "\u7533\u79D1\u96C6\u56E2\u4EE5\u201C\u8BDA\u4FE1\u3001\u521B\u65B0\u3001\u5171\u8D62\u201D\u4E3A\u4F01\u4E1A\u6838\u5FC3\u4EF7\u503C\u89C2\uFF0C\u575A\u6301\u201C\u4EE5\u4EBA\u4E3A\u672C\u201D\u7684\u7ECF\u8425\u7406\u5FF5\uFF0C\u4EE5\u201C\u670D\u52A1\u5BA2\u6237\u3001\u521B\u9020\u4EF7\u503C\u201D\u4E3A\u4F01\u4E1A\u4F7F\u547D\uFF0C\u52AA\u529B\u6253\u9020\u4E00\u6D41\u7684\u4F01\u4E1A\u5F62\u8C61\uFF0C\u521B\u9020\u201C\u548C\u8C10\u201D\u7684\u4F01\u4E1A\u6587\u5316\uFF0C\u4E3A\u5BA2\u6237\u63D0\u4F9B\u201C\u5C0A\u8D35\u3001\u8BDA\u4FE1\u3001\u4E13\u4E1A\u3001\u53EF\u9760\u201D\u7684\u670D\u52A1\u3002"
    }
  },
  {
    name: "\u516C\u53F8\u65B0\u95FB",
    id: 6,
    info: {
      // 假数据
      content: "\u7533\u79D1\u96C6\u56E2\u662F\u4E00\u5BB6\u4E13\u4E1A\u4ECE\u4E8B\u80A1\u4EFD\u5236\u8BC1\u5238\u6295\u8D44\u54A8\u8BE2\u3001\u8D44\u4EA7\u7BA1\u7406\u3001\u79C1\u52DF\u80A1\u6743\u6295\u8D44\u3001\u4FDD\u9669\u7406\u8D22\u3001\u57FA\u91D1\u7BA1\u7406\u3001\u8BC1\u5238\u7ECF\u7EAA\u3001\u8D44\u4EA7\u8BC4\u4F30\u3001\u8D44\u4EA7\u914D\u7F6E\u3001\u8D44\u4EA7\u8FD0\u8425\u3001\u8BC1\u5238\u671F\u8D27\u3001\u8BC1\u5238\u6295\u987E\u3001\u8BC1\u5238\u6295\u8D44\u987E\u95EE\u3001\u8BC1\u5238"
    }
  },
  {
    name: "\u516C\u53F8\u8363\u8A89",
    id: 7,
    info: {
      content: "\u7533\u79D1\u96C6\u56E2\u4EE5\u201C\u8BDA\u4FE1\u3001\u521B\u65B0\u3001\u5171\u8D62\u201D\u4E3A\u4F01\u4E1A\u6838\u5FC3\u4EF7\u503C\u89C2\uFF0C\u575A\u6301\u201C\u4EE5\u4EBA\u4E3A\u672C\u201D\u7684\u7ECF\u8425\u7406\u5FF5\uFF0C\u4EE5\u201C\u670D\u52A1\u5BA2\u6237\u3001\u521B\u9020\u4EF7\u503C\u201D\u4E3A\u4F01\u4E1A\u4F7F\u547D\uFF0C\u52AA\u529B\u6253\u9020\u4E00\u6D41\u7684\u4F01\u4E1A\u5F62\u8C61\uFF0C\u521B\u9020\u201C\u548C\u8C10\u201D\u7684\u4F01\u4E1A\u6587\u5316\uFF0C\u4E3A\u5BA2\u6237\u63D0\u4F9B\u201C\u5C0A\u8D35\u3001\u8BDA\u4FE1\u3001\u4E13\u4E1A\u3001\u53EF\u9760\u201D\u7684\u670D\u52A1\u3002"
    }
  }
];

const _____ = defineWrappedResponseHandler((event) => {
  return listenRequest(event, {
    /**
     * 获取导航列表
     */
    "list": (data) => {
      const id = data.params.id;
      const res = navListLevel1.map((item) => ({
        ...item,
        children: navListLevel2.filter((child) => child.pid === item.id)
      }));
      return id ? res.filter((item) => item.id == id) : res;
    },
    /**
     * 获取详情
     */
    "detail": (data) => {
      const id = data.params.id;
      return channelDetail.find((item) => item.id == id);
    }
  });
});

export { _____ as default };
//# sourceMappingURL=_..._.mjs.map
